//
//  ZDoctorReplyTableViewCell.m
//  DoctorFAQs
//
//  Created by zjq on 17/2/15.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "ZDoctorReplyTableViewCell.h"
#import "ZConsumerView.h"
@interface ZDoctorReplyTableViewCell () {
    UIView * _grayView;
    UIImageView * _styleView; // 此条消息的状态 //绿色的图片
    UILabel * _contextLabel;
    ZConsumerView * _userView;
}


@end
@implementation ZDoctorReplyTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initlizeInterface];
    }
    return self;
}

- (void)initlizeInterface {
    [self makeAddsubView];
    [self addAllSubView];
    [self makeAllSubViewMasnoy];
}
- (void)makeAddsubView {
    _grayView = [[UIView alloc] init];
    _grayView.backgroundColor = MYGRAYCOLOR;
    
    _styleView = [[UIImageView alloc] init];
    _styleView.image = [UIImage imageNamed:@"Label_reply_1"];
    [_styleView setContentMode:UIViewContentModeLeft];
    // 修改imageView的填充属性
    _styleView.clipsToBounds = YES;
    
    _redView = [[UIView alloc] init];
    _redView.layer.cornerRadius = 2;
    _redView.layer.masksToBounds = YES;
    _styleLabel = [[UILabel alloc] init];
    _styleLabel.textAlignment = NSTextAlignmentRight;
//    _styleLabel.text = @"";
    _styleLabel.font = [UIFont systemFontOfSize:13];
    _styleLabel.textColor = KHGaryColor666;
    _contextLabel = [[UILabel alloc] init];
    _contextLabel.numberOfLines = 3;
//    _contextLabel.text = @"";
    _contextLabel.font = [UIFont systemFontOfSize:16];
    _contextLabel.textColor = KHBlackColor;
   
    _redView.backgroundColor = [UIColor redColor];
    _userView = [[ZConsumerView alloc] init];
}
- (void)addAllSubView {
    [self.contentView addSubview:_grayView];
    [self.contentView addSubview:_styleView];
    [self.contentView addSubview:_redView];
    [self.contentView addSubview:_styleLabel];
    [self.contentView addSubview:_contextLabel];
    [self.contentView addSubview:_userView];
    
}
- (void)makeAllSubViewMasnoy {
    [_grayView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.width.equalTo(self);
        make.height.offset(10*ysIZE);
    }];
    [_styleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self);
        make.top.equalTo(_grayView.mas_bottom);
        make.width.offset(200*xsIZE);
        make.height.offset(25*ysIZE);
    }];
    [_styleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-15*xsIZE);
        make.height.offset(13*ysIZE);
        make.top.equalTo(_grayView.mas_bottom).offset(6.5*ysIZE);
        make.width.offset(40*ysIZE);
    }];
    [_redView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_styleLabel.mas_left);
        make.width.height.offset(4*xsIZE);
        make.centerY.equalTo(_styleLabel);
    }];
    [_contextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(13*xsIZE);
        make.right.equalTo(self).offset(-15*xsIZE);
        make.top.equalTo(_grayView).offset(40*ysIZE);
        make.height.offset(65*ysIZE);
    }];
    [_userView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self);
        make.left.equalTo(self);
        make.height.offset(30*ysIZE);
        make.top.equalTo(_contextLabel.mas_bottom).offset(15*ysIZE);
    }];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

// 重写模型set方法
- (void)setDoctorReplyModel:(DoctorReplyModel *)doctorReplyModel {
    _doctorReplyModel = doctorReplyModel;
    // 根据状态设置医生是否回复图片
    if ([_doctorReplyModel.status isEqualToString:@"0"]) {
        _styleView.image = [UIImage imageNamed:@"newweihuifu"];
    }else if ([_doctorReplyModel.status isEqualToString:@"1"]) {
        _styleView.image = [UIImage imageNamed:@"Label_reply_2"];
    }else if ([_doctorReplyModel.status isEqualToString:@"2"]){
        _styleView.image = [UIImage imageNamed:@"newweifukun"];
    }else if ([_doctorReplyModel.status isEqualToString:@"3"]) {
        _styleView.image = [UIImage imageNamed:@"newweipinglun"];
    }else if ([_doctorReplyModel.status isEqualToString:@"4"]) {
        _styleView.image = [UIImage imageNamed:@"Label_reply_1"];
    }

    
    // 判断是否已读
    if ([_doctorReplyModel.is_read isEqualToString:@"1"]) {
        self.redView.hidden = YES;
        _styleLabel.text = @"已读";
    }else {
        self.redView.hidden = NO;
        _styleLabel.text = @"未读";
    }
    //回复内容
    _contextLabel.text = _doctorReplyModel.title;
}

// 重写医生回复个人信息模型set方法
- (void)setPersonInfoModel:(PersonInfoModel *)personInfoModel {
    _userView.personInfoModel = personInfoModel;
    
    
}



@end
